﻿Imports SlimDX.Direct3D9
Imports SlimDX

Public Class ItemCollection
    Dim item As Obje
    Sub New(ByVal itmcTag As Magic.Core.Tag)
        AddHandler itmcTag.TagHasChanged, AddressOf Changed
        Dim itemBlock As Array = itmcTag("item permutations")
        Dim itemCount As Integer = itemBlock.GetLength(0)

        If itemCount > 0 Then
            Dim itemIndex As Integer = itemBlock.GetValue(0, 2)
            item = Managers.ReturnObject(itemIndex)
        End If
    End Sub
    Sub Changed(ByVal itmcTag As Magic.Core.Tag)
        Dim itemBlock As Array = itmcTag("item permutations")
        Dim itemCount As Integer = itemBlock.GetLength(0)

        If itemCount > 0 Then
            Dim itemIndex As Integer = itemBlock.GetValue(0, 2)
            item = Managers.ReturnObject(itemIndex)
        End If
    End Sub
    Sub Render(ByVal xDevice As Device)
        If Not item Is Nothing Then item.Render(xDevice)
    End Sub
    Function Intercept(ByVal eX As Integer, ByVal eY As Integer, ByVal pMatrix As Matrix, ByRef Distance As Single) As Boolean
        Return item.Intercept(eX, eY, pMatrix, Distance)
    End Function
    Sub Dispose()
        item.Dispose()
    End Sub
End Class
